import type { Component, CSSProperties } from 'vue'
import { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'

export type DisplayType =
  | 'boolIcon'
  | 'bools'
  | 'tag'
  | 'tags'
  | 'check'
  | 'checks'
  | 'switch'
  | 'rate'
  | 'slider'
  | 'percentage'
  | 'link'
  | 'links'
  | 'checkbox'
  | 'image'
  | 'images'
  | 'text'
  | 'multiline'
  | 'password'

export interface EventFn<T = any> {
  (data: T): any
}

export interface RenderColumnsFn<T = any> {
  (data: {
    text?: any
    record: T
    index?: number
    column?: BasicTableColumn
  }): any
}

export interface SorterFn {
  compare?: Function
  multiple?: number
}

export enum SortMode {
  Asc = 'ASC',
  Desc = 'DESC'
}

export type ColumnDirection = 'left' | 'center' | 'right'

export interface ColumnOptions {
  boolIconOptions?: Indexable
  boolsOptions?: Indexable
  rateOptions?: Indexable
  sliderOptions?: Indexable
  linkOptions?: Indexable
  linksOptions?: Indexable
  switchOptions?: Indexable
  tagOptions?: Indexable
  tagsOptions?: Indexable
  checkOptions?: Indexable
  checksOptions?: Indexable
  checkboxOptions?: Indexable
  imageOptions?: Indexable
  imagesOptions?: Indexable
  textOptions?: Indexable
  mutilineOptions?: Indexable
  passwordOptions?: Indexable
}
export interface BasicTableColumn<T = any> extends ColumnOptions {
  title: string
  dataIndex: string
  width?: number
  fixed?: boolean | ColumnDirection
  align?: ColumnDirection
  ellipsis?: boolean
  checked?: boolean
  rank?: number
  name?: string
  type?: DisplayType
  isCheck?: boolean
  sorter?: boolean | SorterFn
  component?: PromiseFn
  customRender?: RenderColumnsFn<T>
}

export interface BasicPageParams {
  pageSize: number
  pageNum: number
}

export interface ButtonDisplayType extends ButtonProps {
  style?: CSSProperties | string
}

export enum ConfirmDisplay {
  Modal = 'Modal',
  Popconfirm = 'Popconfirm'
}

export type PopconfirmPlacement =
  | 'topLeft'
  | 'top'
  | 'topRight'
  | 'bottonLeft'
  | 'botton'
  | 'buttonRight'
  | 'leftTop'
  | 'left'
  | 'leftBotton'
  | 'rightTop'
  | 'right'
  | 'rightBotton'

export interface ConfirmBeforeType {
  method?: Function
  warnText: string
}

export interface SencondConfirmType {
  title: string
  display?: ConfirmDisplay
  placement?: PopconfirmPlacement
}

export interface ActionConfigType<T = any> {
  text: string
  type: T
  btnDisplay?: ButtonDisplayType
  confirmBefore?: ConfirmBeforeType
  secondConfirm?: SencondConfirmType
}

export interface RelateCheckType {
  // component: Function
  component?: Component
  title?: string
  data?: Recordable
}